package BC138_KiKi学结构体和指针;

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++){
            list.add(sc.nextInt());
        }

        int del = sc.nextInt();

        ArrayList<Integer> list1 = new ArrayList<>();
        for (Integer e : list){
            if (e != del){
                list1.add(e);
            }
        }

        System.out.println(list1.size());
        for (Integer e : list1){
            System.out.printf("%d ", e);
        }
    }
}
